Repository navigation
Conversation
… build A module that compiles again with an unchanged interface gets a new .cmt, and the next build compared its dependents with that .cmt. Every dependent the previous build had rightly skipped then looked expired and compiled, one dependency level per build. Mark a dependent expired when its .cmt is older than the dependency's .cmi instead, and keep the .cmi's old mtime when a compile leaves its content unchanged, since bsc rewrites it for modules with an interface file and the copy to lib/ocaml gives it a new time on some platforms. Fixes rescript-lang#9487 Signed-off-by: Soham Mirikar <82722112+sohamm20@users.noreply.github.com>
…endents later Nothing caught the extra compiles of rescript-lang#9487. One case covers a plain module (Dep02 -> Dep01) and one a module with a .resi (InternalDep -> Main); reverting the .cmi comparison fails the first, and dropping the mtime restore fails the second. Signed-off-by: Soham Mirikar <82722112+sohamm20@users.noreply.github.com>
The extra module was this bug: the steps before these snapshots leave the Dep02 -> Dep01 -> Main chain partly compiled, and each build compiled one more level of it with no source change. Signed-off-by: Soham Mirikar <82722112+sohamm20@users.noreply.github.com>
The fix changes what users see on every build, so it needs release notes. maintenance/12.x records fixes in CHANGELOG.md directly, as rescript-lang#9318 and rescript-lang#9319 did, rather than in changes/ fragments. Signed-off-by: Soham Mirikar <82722112+sohamm20@users.noreply.github.com>
rescript
@rescript/darwin-arm64
@rescript/darwin-x64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
CHANGELOG.mdentry, as fixes onmaintenance/12.xdo ([12.x] Fix constant folding of a switch on an @as(int) constructor #9318, [12.x] Compare constructor constants by runtime value #9319).CONTRIBUTING.md).git commit -s).Fixes #9487
Problem
When a module compiles again but its
.cmidoesn't change, rewatch correctly skips its dependents in that build. At the start of the next build,mark_modules_with_expired_deps_dirtycompares the dependent's.cmtwith the dependency's.cmt. That.cmtwas rewritten, so every skipped dependent looks expired and compiles. Their.cmidoesn't change either, so the next build compiles the level below them, and so on. In a project with about 2,800 modules, one body edit made every following no-change build compile 770 to 2,400 modules (16 to 40 s).Comparing against the dependency's
.cmitime, as the comment in that function intends, isn't enough on its own:.resion every compile, andbscrewrites the.cmiwith identical bytes and a new mtime.lib/bs→lib/ocamlcopy doesn't keep the mtime (Linux), every compile gives the.cmia new time.Change
compile: rewatch already hashes thelib/ocaml.cmibefore and after compiling a module. When the hash is unchanged, it now restores the.cmi's previous mtime, so the.cmitime only moves when the interface changes.mark_modules_with_expired_deps_dirty: a dependent is expired when its.cmtis older than the dependency's.cmi, not its.cmt. The same change applies to the namespace branch. This also fixes the first match, which read(module.last_compiled_cmt, module.last_compiled_cmt).A dependent still compiles whenever a dependency's interface changed after it last compiled, including after an interrupted build. Interface changes within a build are still found by the existing hash check.
Tests
tests/compile.sh: after a dependency compiles with its interface unchanged, the next build doesn't compile its dependent. One case uses a plain module (Dep02→Dep01) and one a module with a.resi(InternalDep→Main). Reverting the comparison fails the first case; removing the mtime restore fails the second.rename-interface-file.txtandrename-file-with-interface.txt:Compiled 3 modules→Compiled 2 modules. The extra module was this bug: the steps before them leave theDep02→Dep01→Mainchain partly compiled, and each build compiled one more level of it with no source change.cargo testpasses (69),cargo fmt --checkis clean, and the other suite scripts pass (watch, lock, suffix, format, clean, experimental, compiler-args). Run on macOS arm64 with the 12.3.1bsc.Manual checks:
touch A.res, the builds compiled1 1 1 1 1 0modules before the fix and1 0 0 0 0 0after. The same holds whenAhas a.resiand its body changes.@inlinevalue that changes still updates the dependent's JS in the same build..cmtis older than the dependency's.cmi, as after an interrupted build, still compiles..jsfiles matched a clean build.